Quaqua 3.9.5 2007-10-21

ch.randelshofer.quaqua
Class QuaquaTreeUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TreeUI
          extended by javax.swing.plaf.basic.BasicTreeUI
              extended by ch.randelshofer.quaqua.QuaquaTreeUI

public class QuaquaTreeUI
extends javax.swing.plaf.basic.BasicTreeUI

QuaquaTreeUI. XXX - Without copying a substantial amount of code from BasicTreeUI, we can't implement the proper selection behavior for a JTree.

Version:
1.3 2007-08-04 Don't change selection, if a popup trigger occurs on an already selected row. Don't change selection on mouse pressed on a selected row. Change selection on mouse released on a selected row.
1.2.4 2007-01-16 Focus border repainting factored out into QuaquaViewportUI.
1.2.3 2007-01-15 Change foreground color of cell renderer even if it is not an UIResource.
1.2.2 2007-01-11 Selection was not completely repainted on focusLost/focusGained.
1.2.1 2007-01-05 Issue #2: Tree stripes need to be drawn when tree is empty. Issue #6: Selection needs to be drawn differently when tree hasn't focus or is disabled or is on an inactive window.
1.2 2005-09-28 List cells can now be selected on the whole cell line. Inspired by 'FittsLawMouseListener' by Adam Walker. http://www.walkersoftware.net
1.1 2005-07-11 Support for striped style added.
1.0 15 December 2004 Created.
Author:
Werner Randelshofer

Nested Class Summary
 class QuaquaTreeUI.FocusHandler
          This inner class is marked "public" due to a compiler bug.
 class QuaquaTreeUI.MouseHandler
          TreeMouseListener is responsible for updating the selection based on mouse events.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTreeUI
javax.swing.plaf.basic.BasicTreeUI.CellEditorHandler, javax.swing.plaf.basic.BasicTreeUI.ComponentHandler, javax.swing.plaf.basic.BasicTreeUI.KeyHandler, javax.swing.plaf.basic.BasicTreeUI.MouseInputHandler, javax.swing.plaf.basic.BasicTreeUI.NodeDimensionsHandler, javax.swing.plaf.basic.BasicTreeUI.PropertyChangeHandler, javax.swing.plaf.basic.BasicTreeUI.SelectionModelPropertyChangeHandler, javax.swing.plaf.basic.BasicTreeUI.TreeCancelEditingAction, javax.swing.plaf.basic.BasicTreeUI.TreeExpansionHandler, javax.swing.plaf.basic.BasicTreeUI.TreeHomeAction, javax.swing.plaf.basic.BasicTreeUI.TreeIncrementAction, javax.swing.plaf.basic.BasicTreeUI.TreeModelHandler, javax.swing.plaf.basic.BasicTreeUI.TreePageAction, javax.swing.plaf.basic.BasicTreeUI.TreeSelectionHandler, javax.swing.plaf.basic.BasicTreeUI.TreeToggleAction, javax.swing.plaf.basic.BasicTreeUI.TreeTraverseAction
 
Field Summary
 
Fields inherited from class javax.swing.plaf.basic.BasicTreeUI
cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSize
 
Constructor Summary
QuaquaTreeUI()
          Creates a new instance.
 
Method Summary
protected  javax.swing.tree.TreeCellEditor createDefaultCellEditor()
          Creates a default cell editor.
protected  javax.swing.tree.TreeCellRenderer createDefaultCellRenderer()
          Returns the default cell renderer that is used to do the stamping of each node.
protected  java.awt.event.FocusListener createFocusListener()
          Creates the focus listener for handling keyboard navigation in the JTable.
protected  java.awt.event.MouseListener createMouseListener()
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
protected  void installDefaults()
           
protected  boolean isMultiSelectEvent(java.awt.event.MouseEvent event)
          Returning true signifies a mouse event on the node should select from the anchor point.
protected  boolean isToggleEvent(java.awt.event.MouseEvent event)
           
protected  boolean isToggleSelectionEvent(java.awt.event.MouseEvent event)
          Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.
 void paint(java.awt.Graphics gr, javax.swing.JComponent c)
           
protected  void paintHorizontalLine(java.awt.Graphics g, javax.swing.JComponent c, int y, int left, int right)
          Paints a horizontal line.
protected  void paintHorizontalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, javax.swing.tree.TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
          Paints the horizontal part of the leg.
protected  void paintRow(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, javax.swing.tree.TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf, boolean isEnabled, boolean isFocused)
          Paints the renderer part of a row.
protected  void paintVerticalLine(java.awt.Graphics g, javax.swing.JComponent c, int x, int top, int bottom)
          Paints a vertical line.
protected  void paintVerticalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, javax.swing.tree.TreePath path)
          Paints the vertical part of the leg.
protected  void selectPathForEvent(javax.swing.tree.TreePath path, java.awt.event.MouseEvent event)
          Messaged to update the selection based on a MouseEvent over a particular row.
 
Methods inherited from class javax.swing.plaf.basic.BasicTreeUI
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createKeyListener, createLayoutCache, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installKeyboardActions, installListeners, installUI, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isRootVisible, paintExpandControl, paintRow, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateRenderer, updateSize
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuaquaTreeUI

public QuaquaTreeUI()
Creates a new instance.

Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)

installDefaults

protected void installDefaults()
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicTreeUI

createDefaultCellEditor

protected javax.swing.tree.TreeCellEditor createDefaultCellEditor()
Creates a default cell editor.

Overrides:
createDefaultCellEditor in class javax.swing.plaf.basic.BasicTreeUI

createDefaultCellRenderer

protected javax.swing.tree.TreeCellRenderer createDefaultCellRenderer()
Returns the default cell renderer that is used to do the stamping of each node.

Overrides:
createDefaultCellRenderer in class javax.swing.plaf.basic.BasicTreeUI

isToggleSelectionEvent

protected boolean isToggleSelectionEvent(java.awt.event.MouseEvent event)
Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.

Overrides:
isToggleSelectionEvent in class javax.swing.plaf.basic.BasicTreeUI

isToggleEvent

protected boolean isToggleEvent(java.awt.event.MouseEvent event)
Overrides:
isToggleEvent in class javax.swing.plaf.basic.BasicTreeUI

isMultiSelectEvent

protected boolean isMultiSelectEvent(java.awt.event.MouseEvent event)
Returning true signifies a mouse event on the node should select from the anchor point.

Overrides:
isMultiSelectEvent in class javax.swing.plaf.basic.BasicTreeUI

selectPathForEvent

protected void selectPathForEvent(javax.swing.tree.TreePath path,
                                  java.awt.event.MouseEvent event)
Messaged to update the selection based on a MouseEvent over a particular row. If the event is a toggle selection event, the row is either selected, or deselected. If the event identifies a multi selection event, the selection is updated from the anchor point. Otherwise the row is selected, and if the event specified a toggle event the row is expanded/collapsed.

Overrides:
selectPathForEvent in class javax.swing.plaf.basic.BasicTreeUI

createFocusListener

protected java.awt.event.FocusListener createFocusListener()
Creates the focus listener for handling keyboard navigation in the JTable.

Overrides:
createFocusListener in class javax.swing.plaf.basic.BasicTreeUI

createMouseListener

protected java.awt.event.MouseListener createMouseListener()
Overrides:
createMouseListener in class javax.swing.plaf.basic.BasicTreeUI

paint

public void paint(java.awt.Graphics gr,
                  javax.swing.JComponent c)
Overrides:
paint in class javax.swing.plaf.basic.BasicTreeUI

paintVerticalPartOfLeg

protected void paintVerticalPartOfLeg(java.awt.Graphics g,
                                      java.awt.Rectangle clipBounds,
                                      java.awt.Insets insets,
                                      javax.swing.tree.TreePath path)
Paints the vertical part of the leg. The receiver should NOT modify clipBounds, insets.

Overrides:
paintVerticalPartOfLeg in class javax.swing.plaf.basic.BasicTreeUI

paintHorizontalPartOfLeg

protected void paintHorizontalPartOfLeg(java.awt.Graphics g,
                                        java.awt.Rectangle clipBounds,
                                        java.awt.Insets insets,
                                        java.awt.Rectangle bounds,
                                        javax.swing.tree.TreePath path,
                                        int row,
                                        boolean isExpanded,
                                        boolean hasBeenExpanded,
                                        boolean isLeaf)
Paints the horizontal part of the leg. The receiver should NOT modify clipBounds, or insets.

NOTE: parentRow can be -1 if the root is not visible.

Overrides:
paintHorizontalPartOfLeg in class javax.swing.plaf.basic.BasicTreeUI

paintVerticalLine

protected void paintVerticalLine(java.awt.Graphics g,
                                 javax.swing.JComponent c,
                                 int x,
                                 int top,
                                 int bottom)
Paints a vertical line.

Overrides:
paintVerticalLine in class javax.swing.plaf.basic.BasicTreeUI

paintHorizontalLine

protected void paintHorizontalLine(java.awt.Graphics g,
                                   javax.swing.JComponent c,
                                   int y,
                                   int left,
                                   int right)
Paints a horizontal line.

Overrides:
paintHorizontalLine in class javax.swing.plaf.basic.BasicTreeUI

paintRow

protected void paintRow(java.awt.Graphics g,
                        java.awt.Rectangle clipBounds,
                        java.awt.Insets insets,
                        java.awt.Rectangle bounds,
                        javax.swing.tree.TreePath path,
                        int row,
                        boolean isExpanded,
                        boolean hasBeenExpanded,
                        boolean isLeaf,
                        boolean isEnabled,
                        boolean isFocused)
Paints the renderer part of a row. The receiver should NOT modify clipBounds, or insets.


Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.